﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Root.master" AutoEventWireup="true" CodeFile="funds.aspx.cs" Inherits="Default2" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Content" runat="Server">
    <script src="../Scripts/toolbar.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        // <![CDATA[
        function OnkontrChanged(cbbKontr) {
            grd_funds.GetEditor("DOG").PerformCallback(cbbKontr.GetValue().toString());
        }

        function SetEditEnable(value) {
            if (value != null) {
                mMenu.GetItem(1).SetEnabled(false);
                mMenu.GetItem(2).SetEnabled(false);
            } else {
                mMenu.GetItem(1).SetEnabled(true);
                mMenu.GetItem(2).SetEnabled(true);
            }
        }

        var command;
        function OnBeginCallback(s, e) {
            command = e.command;
        }
        function OnEndCallback(s, e) {
            if (command == "STARTDEL") {
                if (s.cpCancelDEL)
                    alert("The record can't be edit, reason: " + s.cpMessage);
            }
        }
        // ]]>
    </script>
    <div class="pageLabel">
        <dx:ASPxLabel ID="lbl_page" runat="server" Text="Движение денежных средств" Font-Size="Medium" Theme="iOS">
        </dx:ASPxLabel>
    </div>
    <div style="float: left; margin-left: 10px; margin-right: 10px;">
        <div>
            <dx:ASPxMenu ID="mMenu" ClientInstanceName="mMenu" runat="server" EnableViewState="False" EncodeHtml="False" SeparatorWidth="2px" BackColor="Transparent"
                SeparatorHeight="15px" ItemSpacing="1px">
                <SeparatorBackgroundImage ImageUrl="~\Images\shared\ToolBars\Office2003\SeparatorBackground.png" />
                <ClientSideEvents ItemClick="function(s, e) { MenuItemClick(e, grd_funds); }" />
                <Items>
                    <dx:MenuItem Name="btn_Insert" Text="" ToolTip="Добавить запись" GroupName="grp_edit" BeginGroup="True">
                        <Image Url="~/Images/shared/edit_add.png">
                        </Image>
                    </dx:MenuItem>
                    <dx:MenuItem GroupName="grp_edit" Name="btn_edit" Text="" ToolTip="Редактировать запись">
                        <Image Url="~/Images/shared/edit.png" UrlDisabled="~/Images/shared/edit_disable.png">
                        </Image>
                    </dx:MenuItem>
                    <dx:MenuItem GroupName="grp_edit" Name="btn_Delete" Text="" ToolTip="Удалит запись">
                        <Image Url="~/Images/shared/editdelete.png" UrlDisabled="~/Images/shared/editdelete_disable.png">
                        </Image>
                    </dx:MenuItem>
                </Items>
            </dx:ASPxMenu>
        </div>
        <dx:ASPxGridView ID="grd_funds" ClientInstanceName="grd_funds" runat="server" AutoGenerateColumns="False" DataSourceID="ds_VZOBOROT" KeyFieldName="CODE" OnRowInserting="grd_funds_RowInserting" OnCellEditorInitialize="grd_funds_CellEditorInitialize">
            <ClientSideEvents FocusedRowChanged="function(s, e) { grd_funds.GetRowValues(grd_funds.GetFocusedRowIndex(), 'SCHET', SetEditEnable);}" />
            <Columns>
                <dx:GridViewDataTextColumn Caption="Код" FieldName="CODE" ReadOnly="True" VisibleIndex="0">
                    <EditFormSettings Visible="False" />
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataComboBoxColumn Caption="Договор" FieldName="DOG" VisibleIndex="2">
                    <PropertiesComboBox DataSourceID="ds_DOG" TextField="NOMDOG" ValueField="CODE" ValueType="System.Int32">
                    </PropertiesComboBox>
                    <EditFormSettings VisibleIndex="2" />
                </dx:GridViewDataComboBoxColumn>
                <dx:GridViewDataDateColumn Caption="Дата проводки" FieldName="DATA" VisibleIndex="3">
                    <EditFormSettings VisibleIndex="1" />
                </dx:GridViewDataDateColumn>
                <dx:GridViewDataComboBoxColumn Caption="Контрагент" FieldName="KONTRAGENT" VisibleIndex="1">
                    <PropertiesComboBox DataSourceID="ds_KONTR" TextField="NAME" ValueField="CODE" ValueType="System.Int32">
                        <ClientSideEvents SelectedIndexChanged="function(s, e) { OnkontrChanged(s);}"
                            ButtonClick="function(s, e) { s.SetSelectedIndex(-1); grd_funds.GetEditor('DOG').PerformCallback(-1); }" />
                        <Buttons>
                            <dx:EditButton Text="X" ToolTip="очистить">
                            </dx:EditButton>
                        </Buttons>
                    </PropertiesComboBox>
                    <EditFormSettings VisibleIndex="0" />
                </dx:GridViewDataComboBoxColumn>
                <dx:GridViewDataTextColumn Caption="Счет №" FieldName="SCHET" VisibleIndex="4">
                    <EditFormSettings Visible="False" />
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn Caption="Начисления" FieldName="NACH" VisibleIndex="5">
                    <EditFormSettings VisibleIndex="3" />
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn Caption="Оплаты" FieldName="OPL" VisibleIndex="6">
                    <EditFormSettings VisibleIndex="5" />
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn Caption="Примечание" FieldName="NOTE" VisibleIndex="7">
                </dx:GridViewDataTextColumn>
            </Columns>
            <SettingsBehavior AllowFocusedRow="True" ConfirmDelete="True" EnableCustomizationWindow="true" AllowSelectByRowClick="True" AllowSelectSingleRowOnly="True" />
            <SettingsPager AlwaysShowPager="True">
                <PageSizeItemSettings Visible="True">
                </PageSizeItemSettings>
            </SettingsPager>
        </dx:ASPxGridView>
        <asp:EntityDataSource ID="ds_VZOBOROT" runat="server" ConnectionString="name=RegistRar" DefaultContainerName="RegistRar" EnableDelete="True" EnableFlattening="False" EnableInsert="True" EnableUpdate="True" EntitySetName="VZOBOROT">
        </asp:EntityDataSource>
        <asp:EntityDataSource ID="ds_DOG" runat="server" ConnectionString="name=RegistRar" DefaultContainerName="RegistRar" EnableFlattening="False" EntitySetName="DOG" Select="it.[CODE], it.[NOMDOG]">
        </asp:EntityDataSource>
        <asp:EntityDataSource ID="ds_KONTR" runat="server" ConnectionString="name=RegistRar" DefaultContainerName="RegistRar" EnableFlattening="False" EntitySetName="KONTRAGENT" Select="it.[CODE], it.[NAME]">
        </asp:EntityDataSource>
    </div>
</asp:Content>

